package com.lewis.exception;

import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * 控制器切面全局异常处理，尝试捕获过滤器异常
 * @author jiaqi.liu
 *
 */
@ControllerAdvice
public class ExceptionHandlerCneter {
	
	
	/**
	 * 未授权异常处理
	 * @param e
	 * @return
	 */
	@ExceptionHandler(AuthorizationException.class)
	@ResponseBody
	public String authorizationExceptionHandler(AuthorizationException e){
		return "have no permission";
	}
			
	/**
	 * 
	 * @param e
	 * @return
	 */
	@ExceptionHandler(Exception.class)
	@ResponseBody
	public String exceptionHandler(Exception e){
		System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"+e.getMessage()+"^^^^^^^^^^^^^^^^^^^^^^^^^^");
		return e.getMessage();
	}

}
